package cn.zyq.demo.system.enums.core;

import cn.zyq.demo.system.exception.BusinessException;

public enum PlatformSourceTypeEnum {
    MGT("管理系统端", 1),
    MP("小程序端", 2),
    H5("H5端", 3),
    ;
    private final String key;
    private final Integer value;

    PlatformSourceTypeEnum(String key, Integer value) {
        this.key = key;
        this.value = value;
    }


    public static String getKeyByValue(Integer value) {
        for (PlatformSourceTypeEnum item : PlatformSourceTypeEnum.values()) {
            if (item.value.equals(value)) return item.key;
        }
        throw new BusinessException(ResponseCodeEnum.ERROR, "无效的value值");
    }

    public static String getValueByKey(String key) {
        for (PlatformSourceTypeEnum item : PlatformSourceTypeEnum.values()) {
            if (item.key.equals(key)) return item.getValue().toString();
        }
        throw new BusinessException(ResponseCodeEnum.ERROR, "无效的key值");
    }


    public Integer getValue() {
        return value;
    }

}
